<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">新闻客户端</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded">
				<h5>欢迎登陆某讯新闻客户端&nbsp;&nbsp;[<a href="javascript:;"id="out">注销</a>]</h5>
			</div>
			<ul class="mui-table-view" id="list_ul">
			    
			</ul>
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function(){
				var out = document.getElementById("out");
				out.addEventListener('tap',function(){
					mui.ajax('http://api.jiunixing.com/appNews/index.php?c=Account&a=logout',{
						timeout:15000,
						success:function(){
							mui.openWindow({
								url:'./index.html',
								id:'index',
								timeout:15000,
								show:{
									aniShow:'pop-in',
								}
							})
						}
					});
					return;
				})
				var listUl = document.getElementById("list_ul");
				mui.ajax('http://api.jiunixing.com/appNews/index.php?c=Arc&a=lists',{
					type:'get',
					timeout:20000,
					dataType:'json',
					success:function(data){
						var str = '';
						for (var i=0;i<data.length;i++) {
							//组合字符串，然后填充到ul中
							str += '<li class="mui-table-view-cell mui-media" data-id="'+i+'"><a href="javascript:;">';
							str += '<img class="mui-media-object mui-pull-left" src="'+data[i].img+'">';
							str += '<div class="mui-media-body">'+data[i].title+ '<p class="mui-ellipsis">'+data[i].des+'</p></div></a></li>';
						}
						listUl.innerHTML = str;
						//点击li发送ajax必须放在成功的这个数据里面，因为要用到接口传过来的数据，
						mui('#list_ul').on('tap','li',function(){
							mui.openWindow({
								url:'./detail.html',
								id : 'detail',
								timeout:20000,
								extras:{
		    						title:data[this.getAttribute('data-id')].title,
									des:data[this.getAttribute('data-id')].des,
								}
							})
						})
					}
				})
			})
		</script>
	</body>

</html>